﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Entity.EntityValidation
{
    /// <summary>
    /// 为空验证
    /// </summary>
    [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false)]
    public class RequiredValueAttribute : EntityValidationAttribute
    {
        public bool AllowEmptyStrings { get; set; }
        public RequiredValueAttribute(MessageType messageType, params object[] args) :
            base(messageType, args)
        { }
        public override bool IsValid(object value)
        {
            return new System.ComponentModel.DataAnnotations.RequiredAttribute { AllowEmptyStrings = this.AllowEmptyStrings }.IsValid(value);
        }
    }
}
